package com.globalwave.datasync.sqlgen;

import com.globalwave.datasync.SyncColumn;
import com.globalwave.datasync.SyncConfig;
import com.globalwave.datasync.SyncTable;

public class IncrementInsertModeSqlGenerator extends BaseBatchSqlGenerator {

	
	public IncrementInsertModeSqlGenerator(SyncConfig config) {
		super(config);
	}


	@Override
	public void buildSourceUpdateSQL(){
		StringBuffer sqlBuffer = new StringBuffer() ;

		SyncTable table = config.getSource() ;
		SyncColumn[] keys = table.getKeys();

		sqlBuffer.append(" update ").append(table.getTableName()).append(" set ") ;
        
		sqlBuffer.append(keys[0].getRefColumnsCode()).append("=? ");
        
		sqlBuffer.append(" where ").append(keys[0].getSyncColumnsCode()).append(">=? and ")
		         .append(keys[0].getSyncColumnsCode()).append("<=? ") ;
        
        config.setSourceUpdateSQL(sqlBuffer.toString());
	}
	
}
